﻿#include "recordwidget.h"
#include "ui_recordwidget.h"

RecordWidget::RecordWidget(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::RecordWidget)
{
    ui->setupUi(this);

//    //调整行和列
//    ui->tableWidget->setRowCount(20);
//    ui->tableWidget->setColumnCount(2);

//    //修改行列标题
//    QStringList strlist;
//    strlist << tr("操作类型") << tr("操作时间");
//    ui->tableWidget->setHorizontalHeaderLabels(strlist);

    //初始化
    /* setItem(行，列，内容) */
    InitTable();
}

RecordWidget::~RecordWidget()
{
    delete ui;
}

void RecordWidget::on_btn_main_clicked()
{
    this->hide();
    emit goMainWidget();
}

void RecordWidget::on_btn_setting_clicked()
{
    this->hide();
    emit goSettingWidget();
}

void RecordWidget::on_btn_password_clicked()
{
    this->hide();
    emit goPasswordWidget();
}

void RecordWidget::on_btn_serial_clicked()
{
    this->hide();
    emit goSerialWindow();
}

void RecordWidget::InitTable()
{
    QList<QString> strtype;
    QList<QString> strtime;

    strtype << tr("增加数据") << tr("查看数据");
    strtime << tr("2023/8/25 16:00") << tr("2303/8/25 17:00");

    for(int irow=0; irow < 2; irow++)
    {
        int icolumn = 0;
        QTableWidgetItem *pitem = new QTableWidgetItem(strtype.at(irow));
        //插入第一列
        ui->tableWidget->setItem(irow, icolumn++, pitem);
        //插入第二列
        ui->tableWidget->setItem(irow, icolumn++, new QTableWidgetItem(strtime.at(irow)));
    }
}
